#include<cstdio>
#include<cstring>
char p[1000010];
int next[1000010];
int len;
void make_next()
{
	len=strlen(p+1);
	next[1]=0;
	int k=0;
	for(int i=2;i<=len;i++)
	{
		while(k>0&&p[k+1]!=p[i])
			k=next[k];
		if(p[k+1]==p[i])k++;
		next[i]=k;
	}
}
int main()
{
	freopen("test.in","r",stdin);
	while(scanf("%s",p+1),p[1]!='.')
	{
		memset(next,0,sizeof(next));
		make_next();
		int t=len-next[len];
		printf("%d\n",len%t==0?len/t:1);
	}
	return 0;
}

	
